<extend name="Layout:base"/>

<block name="title">比赛报名系统</block>

<block name="css"></block>

<block name="main">
    <div class="container">
        <div class="section" id="mysec">
            <div class="row">
                <form class="col s12" id="from" method="post" action="{:U('Stuform/teamAdd')}">
                    <div class="row" id="form">
                        <div class="row">
                            <div class="input-field col s12">
                                <input style="font-size: 30px" type="text" class="validate" value="蓝桥杯" disabled>
                                <input id="enid" name="enid" type="hidden" value="{$_GET['enid']}">
                                <label for="name">你们所参加的比赛：<p id="t"></p></label>
                            </div>
                        </div>
                        <div class="row">
                            <div class="input-field col s12">
                                <input placeholder="请输入姓名" id="name" type="text" class="validate">
                                <input id="iname" name="name" type="hidden" value="">
                                <label for="name">团队队长：</label>
                            </div>
                        </div>
                        <div class="row">
                            <div class="input-field col s12">
                                <input id="name1" type="text" class="validate">
                                <input id="iname1" name="name1" type="hidden" value="">
                                <label for="name1">队员1：</label>
                            </div>
                        </div>
                        <div class="row">
                            <div class="input-field col s12">
                                <input id="name2" type="text" class="validate">
                                <input id="iname2" name="name2" type="hidden" value="">
                                <label for="name2">队员2：</label>
                            </div>
                        </div>
                        <div class="row" id="hd3" hidden>
                            <div class="input-field col s12">
                                <input id="name3" type="text" class="validate">
                                <input id="iname3" name="name3" type="hidden" value="">
                                <label for="name3">队员3：</label>
                            </div>
                        </div>
                        <div class="row" id="hd4" hidden>
                            <div class="input-field col s12">
                                <input id="name4" type="text" class="validate">
                                <input id="iname4" name="name4" type="hidden" value="">
                                <label for="name4">队员4：</label>
                            </div>
                        </div>
                    </div>

                    <a id="addin" class="btn waves-effect waves-light blue" type="#" name="action">添加一个队员</a>

                    <div class="clearfix"></div>
                    <br>
                    <br>
                    <div class="row center">
                        <input class="waves-effect waves-light btn green" type="submit" value="提交报名">
                        &nbsp;
                        <input class="waves-effect waves-light btn grey" type="reset" value="重新填写">
                    </div>
                </form>
            </div>
        </div>
    </div>


</block>

<block name="js">
    <script>

        $i = 3;

        $("#addin").click(function () {
            if ($i < 5) {
                $("#hd" + $i).show();
                $i++;
            } else {
                Materialize.toast('一个团队最多能组5人!', 4000)
            }
        });

        $("#name").autocomplete({
            minLength: 1,
            source: "__URL__/everyOne",
            messages: {
                noResults: '',
                results: function () {
                }
            },
            select: function (event, ui) {

                $("#name").val(ui.item.label);
                $("#iname").val(ui.item.value);

                event.preventDefault();
            }
        });

        $("#name1").autocomplete({
            minLength: 1,
            source: "__URL__/everyOne",
            messages: {
                noResults: '',
                results: function () {
                }
            },
            select: function (event, ui) {
                $("#name1").val(ui.item.label);
                $("#iname1").val(ui.item.value);
                event.preventDefault();
            }
        });

        $("#name2").autocomplete({
            minLength: 1,
            source: "__URL__/everyOne",
            messages: {
                noResults: '',
                results: function () {
                }
            },
            select: function (event, ui) {
                $("#name2").val(ui.item.label);
                $("#iname2").val(ui.item.value);
                event.preventDefault();
            }
        });

        $("#name3").autocomplete({
            minLength: 1,
            source: "__URL__/everyOne",
            messages: {
                noResults: '',
                results: function () {
                }
            },
            select: function (event, ui) {
                $("#name3").val(ui.item.label);
                $("#iname3").val(ui.item.value);
                event.preventDefault();
            }
        });

        $("#name4").autocomplete({
            minLength: 1,
            source: "__URL__/everyOne",
            messages: {
                noResults: '',
                results: function () {
                }
            },
            select: function (event, ui) {
                $("#name4").val(ui.item.label);
                $("#iname4").val(ui.item.value);
                event.preventDefault();
            }
        });


    </script>
</block>